﻿using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;

namespace Tiscs.Practices.Web.Services.Client
{
    /// <summary>
    /// Cookie管理器终结点行为。
    /// </summary>
    public class CookieManagerEndpointBehavior : IEndpointBehavior
    {
        /// <summary>
        /// 添加终结点参数。
        /// </summary>
        /// <param name="endpoint">服务终结点。</param>
        /// <param name="bindingParameters">参数列表。</param>
        public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
        {
            return;
        }

        /// <summary>
        /// 修改客户端行为或扩展。
        /// </summary>
        /// <param name="endpoint">服务终结点。</param>
        /// <param name="clientRuntime">客户端运行时。</param>
        public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(CookieManagerMessageInspector.Instance);
        }

        /// <summary>
        /// 修改服务端行为或扩展。
        /// </summary>
        /// <param name="endpoint">服务终结点。</param>
        /// <param name="endpointDispatcher">终结点调度程序。</param>
        public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
        {
            return;
        }

        /// <summary>
        /// 验证服务终结点。
        /// </summary>
        /// <param name="endpoint">服务终结点。</param>
        public void Validate(ServiceEndpoint endpoint)
        {
            return;
        }
    }
}
